package pers.lan.hash;

import java.util.HashSet;
import java.util.Set;

/**
 * @author <p><a href="mailto:1728209643@qq.com">XiaoSan</a>
 * @date 2019/9/9 8:10 AM
 */
public class LC_771 {

    public int numJewelsInStones(String J, String S) {
        char[] chars = J.toCharArray();
        Set<Character> set = new HashSet<>(chars.length);
        for (char c : chars) {
            set.add(c);
        }
        chars = S.toCharArray();
        int i = 0;
        for (int j = 0; j < chars.length; j++) {
            if (set.contains(chars[j])) {
                i++;
            }
        }
        return i;
    }
}
